package com.amarsoft.are.log.impl.simple;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Properties;
import java.util.TimeZone;

public class SimpleHandler
{
  protected static final Properties props = new Properties();
  protected static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS zzz";
  protected static DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS zzz");
  private int logLevel = 3;
  private Formatter formatter;

  public SimpleHandler()
  {
    configure();
  }

  public void configure()
  {
    dateFormatter.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
  }

  protected static String getStringProperty(String paramString)
  {
    String str = null;
    try
    {
      str = props.getProperty(paramString);
    }
    catch (SecurityException localSecurityException)
    {
    }
    return str;
  }

  protected static String getStringProperty(String paramString1, String paramString2)
  {
    String str = getStringProperty(paramString1);
    return ((str == null) ? paramString2 : str);
  }

  protected static boolean getBooleanProperty(String paramString, boolean paramBoolean)
  {
    String str = getStringProperty(paramString);
    return ((str == null) ? paramBoolean : "true".equalsIgnoreCase(str));
  }

  public int getLogLevel()
  {
    return this.logLevel;
  }

  public void setLogLevel(int paramInt)
  {
    this.logLevel = paramInt;
  }

  public void setLogLevel(String paramString)
  {
    if ("all".equalsIgnoreCase(paramString))
    {
      setLogLevel(0);
    }
    else if ("trace".equalsIgnoreCase(paramString))
    {
      setLogLevel(1);
    }
    else if ("debug".equalsIgnoreCase(paramString))
    {
      setLogLevel(2);
    }
    else if ("info".equalsIgnoreCase(paramString))
    {
      setLogLevel(3);
    }
    else if ("warn".equalsIgnoreCase(paramString))
    {
      setLogLevel(4);
    }
    else if ("error".equalsIgnoreCase(paramString))
    {
      setLogLevel(5);
    }
    else if ("fatal".equalsIgnoreCase(paramString))
    {
      setLogLevel(6);
    }
    else
    {
      if (!("off".equalsIgnoreCase(paramString)))
        return;
      setLogLevel(7);
    }
  }

  public boolean isLevelEnabled(int paramInt)
  {
    return (paramInt >= this.logLevel);
  }

  public static Properties getProperties()
  {
    return props;
  }

  public void setFormatter(Formatter paramFormatter)
    throws SecurityException
  {
    paramFormatter.getClass();
    this.formatter = paramFormatter;
  }

  public Formatter getFormatter()
  {
    return this.formatter;
  }

  public void close()
    throws SecurityException
  {
  }

  public void flush()
  {
  }

  public void publish(LogRecord paramLogRecord)
  {
    Formatter localFormatter = getFormatter();
    if (localFormatter == null)
      publish(paramLogRecord.getMessage());
    else
      publish(localFormatter.format(paramLogRecord));
  }

  public void publish(String paramString)
  {
    System.out.println(dateFormatter.format(Calendar.getInstance().getTime()) + " " + paramString);
  }
}

/* Location:           D:\办公软件\反编译工具\jar\are-1.0b96.jar
 * Qualified Name:     com.amarsoft.are.log.impl.simple.SimpleHandler
 * JD-Core Version:    0.5.3
 */